﻿using System;
using System.Net;

//"Smart" StarShip types with extension methods
namespace SCG.SolarVengeanceEngine
{
    //StarShip types
    public enum StarShipType { 
        WarShip, ScanShip, Drone, EMine, SpyShip, 
        Freighter, InkSpot, CloakDetector, Tug, HijackShip,
        ShieldGenerator, CommandShip, DoppleShip, RepairShip, DoomMissile,
        NukeMissile, MineSweeper, GravShip, StarTillery, TechShip,
        JumpGateShip, BattleStation, BeamShip, MadBomb, Elite,
        ParalyShip, RemoteViewer, Director, Carrier, Refinery,
        Zealot }

    //Extension methods
    public static class SSTExtensions
    {
        //Get the base building cost
        public static int GetBaseCost(this StarShipType st)
        {
            return _baseCost[(int)st];
        }

        //Get whether or not the shiptype has fixed engines
        public static int GetFixedEngines(this StarShipType st)
        {
            return _fixedEngines[(int)st];
        }

        //Get the primary system cost multiple
        public static double GetCostMultiple(this StarShipType st)
        {
            return _costMultiple[(int)st];
        }

        //Get the primary system name
        public static string GetPrimarySystemName(this StarShipType st)
        {
            return _primarySystemNames[(int)st];
        }

        //Get the primary system abbreviation
        public static string GetPrimarySystemAbbreviation(this StarShipType st)
        {
            int idx = (int)st;
            if (_primarySystemNames[idx] == "")
                return "";
            else
                return _primarySystemNames[idx].Substring(0, 1);
        }

        //private members
        private static int[] _baseCost = 
        { 
            1, 1, 1, 10, 3, 
            1, 1, 1, 6, 5, 
            20, 10, 6, 1, 2, 
            2, 4, 25, 5, 25, 
            40, 40, 30, 1, 10, 
            7, 33, 1, 13, 58,
            -2 
        };
        public static int[] _fixedEngines = 
        { 
            0, 0, 0, 1, 0, 
            0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 
            0, 0, 0, 0, 3, 
            0, 6, 0, 0, 0, 
            0, 3, 0, 0, 6,
            0 
        };
        private static double[] _costMultiple = 
        { 
            0.7, 0.6, 0, 0, 1.2, 
            0.4, 0, 0.6, 0, 0, 
            0, 1, 0.9, 0, 0.8, 
            0.9, 0.75, 0, 1.1, 0, 
            0, 0.4, 3.0, 2.1, 0.9, 
            0.8, 3.0, 0.6, 0.9, 0,
            0.45 
        };
        private static string[] _primarySystemNames = 
        { 
            "Weapons", "Scanners", "", "", "Scanners", 
            "Cargo Bays", "", "Range", "", "",
            "", "Range", "Weapons", "", "Warheads", 
            "Warheads", "Armor", "", "Range", "", 
            "", "Hull", "Range", "Range", "Weapons", 
            "Range", "Range", "Range", "Bays", "",
            "Influence"
        };
    }
}
